FOR EACH pt_mstr WHERE pt_pm_code = "M" AND PT_PART BEGINS "P" NO-LOCK:
    IF (TODAY - PT_ADDED ) <= 30  THEN
        PT_PART_TYPE = "FG-A"
    ELSE DO:
       FIND LAST tr_hist WHERE TR_TYPE = "ISS-SO" AND TR_PART = PT_PART NO-LOCK NO-ERROR.
       IF AVAILABLE TR_HIST THEN DO:
           IF (TODAY - TR_SHIP_DATE <= 180 ) THEN
             ASSIGN PT_PART_TYPE = "FG-A".
           ELSE
              IF (TODAY - TR_SHIP_DATE) > 180 AND (TODAY - TR_SHIP_DATE) <=360 THEN
                  ASSIGN PT_PART_TYPE = "FG-B" .
              ELSE
                  ( TODAY - TR_SHIP_DATE ) > 360 THEN 
                      ASSIGN PT_PART_TYPE = "FG-C".
       END ELSE 
          ASSIGN PT_PART_TYPE = "FG-C".
    END.
   
END.
